package com.swss.g.assets.action;

import java.util.List;
import com.swss.g.assets.bean.Asset;
import com.swss.g.assets.bean.ChangeAsset;
import com.swss.g.assets.service.AssetService;
import com.swss.g.assets.service.ChangeService;
import com.swss.g.base.BaseAction;
import com.swss.g.sys.service.CurrentPeriodService;
import com.swss.g.sys.service.SysService;
import com.swss.g.user.bean.Role;
import com.swss.g.user.bean.User;
import com.swss.g.user.service.UserService;
import com.swss.util.Pagination;

public class SearchAction extends BaseAction {
	/**
	 * 
	 */
	private static final long serialVersionUID = 3016348148306946228L;
	private List<?> fundSubList;
	private List<?> useDirList;
	private List<?> nowStatusList;
	private List<?> astSourceList;
	private List<?> chargeOffDeptList;

	// 查询类别
	private Integer searchType;
	private String searchURL;

	/**
	 * bean
	 */

	private User user;

	private Pagination<?> pagination;

	private Role role;

	private Asset asset;

	private ChangeAsset changeAsset;

	/**
	 * service
	 * 
	 * @return
	 */
	private AssetService assetService;
	private ChangeService changeService;
	private CurrentPeriodService currentPeriodService;
	private UserService userService;
	private SysService sysService;

	public String searchBarInit() {
		try {
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return "searchBar";
	}
	/**
	 * @param searchType :
	 * 主库快速查询中转 0.在账查询 1.登记管理 2.设备初审 3.财务审核4.财务恢复 5.终审前查询 6.资产申报申请
	 * 7.增减值申请8.处置管理9.处置初审10.处置财审11.处置财审恢复
	 * 
	 * @return
	 */
	public String searchController() {
		try {
			if (this.searchType == null) {
				this.searchType = 0;
			}
			String url = "/swss";
			switch (this.searchType) {
			case 0:
				url += "/asset/ast_findComplex.action";
				break;
			case 1:
				url += "/asset/ast_findAstNotAduit.action";
				break;
			case 2:
				url += "/asset/ast_findAstFirstAduit.action";
				break;
			case 3:
				url += "/asset/fin_findNotAduit.action";
				break;
			case 4:
				url+="/asset/fin_finthroughAduit.action";
				break;
			case 5:
				url += "/asset/ast_findAstLastAduit.action";
				break;
			case 6:
				url += "/asset/ch_findChangeApply.action"; 
				break;
			case 7:
				url += "/asset/ch_findChangeApplyAdd.action";
				break;
			case 8:
				url += "/asset/ch_chageManage.action";
				break;
			case 9:
				url += "/asset/ch_findChangeFirstAduit.action";
				break;
			case 10:
				url += "/asset/ch_findChangeFinanceAduit.action";
				break;
			case 11:
				url += "/asset/ch_findChangeFinancethroughAduit.action";
				break;
			case 12:
				url += "/asset/ch_findChangeLastAduit.action";
				break;
			case 13:
				url += "/asset/ch_findChangeApplyRecovery.action";
				break;
			default:
				url += "";
				break;
			}
			this.searchURL = url;
			fundSubList = this.getSysService().getFundSub();
			useDirList = this.getSysService().getUseDir();
			nowStatusList = this.getSysService().getNowStatus();
			astSourceList = this.getSysService().getAstSource();
			chargeOffDeptList = this.getSysService().getChargeOffDept();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		//区分处置通用查询或在账通用查询方式
		if (this.searchType == 8 || this.searchType == 9
				|| this.searchType == 10 || this.searchType == 11|| this.searchType == 12|| this.searchType == 13)
			return "changesearchPage";
		else
			return "searchPage";
	}

	/**
	 * 主库高级查询中转 0.在账查询 6.处置申报7.增减值申请8.处置管理9.处置初审10.处置财审11.处置财审恢复
	 * 
	 * @return
	 */
	public String searchComplexController() {
		try {
			if (this.searchType == null) {
				this.searchType = 0;
			}
			String url = "/swss";
			switch (this.searchType) {
			case 0:
				url += "/asset/ast_findComplex.action";
				break;
			case 6:
				url+="/asset/ch_findChangeApply.action";
				break;
			case 7:
				url+="/asset/ch_findChangeApplyAdd.action";
				break;
			case 8:
				url+="/asset/ch_chageManage.action";
				break;
			case 9:
				url += "/asset/ch_findChangeFirstAduit.action";
				break;
			case 10:
				url += "/asset/ch_findChangeFinanceAduit.action";
				break;
			case 11:
				url += "/asset/ch_findChangeFinancethroughAduit.action";
				break;
			case 12:
				url += "/asset/ch_findChangeLastAduit.action";
				break;
			case 13:
				url += "/asset/ch_findChangeApplyRecovery.action";
				break;
			default:
				url += "";
				break;
			}
			this.searchURL = url;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return "searchComplexPage";
	}
	/**通过一个单据号返回对应的条数
	 * type 1.在账 main 2.变动 changemain 
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public String findOneDanJuNoAstByExamply() {
		try {
			Integer type = Integer.parseInt(this.getRequest().getParameter("type"));
			if (this.pagination == null) {
				pagination = new Pagination();
			}
			if (this.getRequest().getParameter("danjuNo") != null) {
				pagination = this.getAssetService().findListAstByDanJuNo(pagination,this.getRequest().getParameter("danjuNo"),type);
			}
			this.print("{\"count\":\"" + pagination.getRowcount() + "\"}");
		} catch (Exception e) {
			e.printStackTrace();
			return INPUT;
		}
		return null;
	}

	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Pagination<?> getPagination() {
		return pagination;
	}

	public void setPagination(Pagination<?> pagination) {
		this.pagination = pagination;
	}

	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}
	public SysService getSysService() {
		return sysService;
	}

	public void setSysService(SysService sysService) {
		this.sysService = sysService;
	}

	public List<?> getFundSubList() {
		return fundSubList;
	}

	public void setFundSubList(List<?> fundSubList) {
		this.fundSubList = fundSubList;
	}

	public List<?> getUseDirList() {
		return useDirList;
	}

	public void setUseDirList(List<?> useDirList) {
		this.useDirList = useDirList;
	}

	public List<?> getNowStatusList() {
		return nowStatusList;
	}

	public void setNowStatusList(List<?> nowStatusList) {
		this.nowStatusList = nowStatusList;
	}

	public List<?> getAstSourceList() {
		return astSourceList;
	}

	public void setAstSourceList(List<?> astSourceList) {
		this.astSourceList = astSourceList;
	}

	public CurrentPeriodService getCurrentPeriodService() {
		return currentPeriodService;
	}

	public void setCurrentPeriodService(
			CurrentPeriodService currentPeriodService) {
		this.currentPeriodService = currentPeriodService;
	}

	public Asset getAsset() {
		return asset;
	}

	public void setAsset(Asset asset) {
		this.asset = asset;
	}

	public AssetService getAssetService() {
		return assetService;
	}

	public void setAssetService(AssetService assetService) {
		this.assetService = assetService;
	}

	public List<?> getChargeOffDeptList() {
		return chargeOffDeptList;
	}

	public void setChargeOffDeptList(List<?> chargeOffDeptList) {
		this.chargeOffDeptList = chargeOffDeptList;
	}
	public Integer getSearchType() {
		return searchType;
	}

	public void setSearchType(Integer searchType) {
		this.searchType = searchType;
	}

	public String getSearchURL() {
		return searchURL;
	}

	public void setSearchURL(String searchURL) {
		this.searchURL = searchURL;
	}

	public ChangeAsset getChangeAsset() {
		return changeAsset;
	}

	public void setChangeAsset(ChangeAsset changeAsset) {
		this.changeAsset = changeAsset;
	}

	public ChangeService getChangeService() {
		return changeService;
	}

	public void setChangeService(ChangeService changeService) {
		this.changeService = changeService;
	}
}
